package com.mt;

import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.junit.Test;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.amqp.rabbit.annotation.EnableRabbit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
//import org.springframework.context.annotation.ComponentScan;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
//import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableAsync;

import java.io.IOException;

@EnableAsync
@MapperScan({"com.mt.**.mapper","com.mt.**.dao"})
//
//@ComponentScan(basePackages = {"com.mt.common","com.ddd.dev.generator","com.mt.mall","org.jeecg.modules.jmreport"})
@ComponentScan(basePackages = {"com.mt.common","com.mt.mall"})
@SpringBootApplication(exclude = MongoAutoConfiguration.class)
//@EnableJpaAuditing
@EnableRabbit
public class ErpWebApplication {

    public static void main(String[] args) {
        SpringApplication.run(ErpWebApplication.class, args);
    }

    //private final String BASE_PACKAGE = "com.mt.restaurant";
    //private final String RESOURCE_PATTERN = "/controller/**/*.class";
    //@Bean
    //public void test() {
    //	Map<String, Class> handlerMap = new HashMap<String, Class>();
    //
    //	//spring工具类，可以获取指定路径下的全部类
    //	ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
    //	try {
    //
    //		String pattern = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX +
    //				ClassUtils.convertClassNameToResourcePath(BASE_PACKAGE) + RESOURCE_PATTERN;
    //		org.springframework.core.io.Resource[] resources = resourcePatternResolver.getResources(pattern);
    //		//MetadataReader 的工厂类
    //		MetadataReaderFactory readerfactory = new CachingMetadataReaderFactory(resourcePatternResolver);
    //		for (org.springframework.core.io.Resource resource : resources) {
    //			//用于读取类信息
    //			MetadataReader reader = readerfactory.getMetadataReader(resource);
    //			//扫描到的class
    //			String classname = reader.getClassMetadata().getClassName();
    //			Class<?> clazz = Class.forName(classname);
    //			Method[] methods = clazz.getMethods();
    //			List<String> list=new ArrayList<>();
    //			for(Method method : methods){
    //				PreAuthorize anno =method.getAnnotation(PreAuthorize.class);
    //				if(anno!=null) {
    //					String value = anno.value();
    //					value=value.substring(14,value.length()-2);
    //
    //					list.add(value);
    //				}
    //			}
    //			//value);
    //
    //			//判断是否有指定主解
    //			PreAuthorize anno = clazz.getAnnotation(PreAuthorize.class);
    //			if (anno != null) {
    //				//将注解中的类型值作为key，对应的类作为 value
    //				handlerMap.put(classname, clazz);
    //			}
    //		}
    //	} catch (IOException | ClassNotFoundException e) {
    //		System.out.println(e.getMessage());
    //	}
    //}


}
